﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;

namespace HealthExamination.HardwareDrivers.Commons
{
    public static class ImageHelper
    {
        /// <summary>
        /// 字节流转换成图片
        /// </summary>
        /// <param name="strimg">字节流图片</param>
        /// <param name="newpath">保存的图片路径</param>
        /// <returns>图片路径</returns>
        public static bool BytToImgpath(byte[] byt, string newpath)
        {
            bool bre = false;
            // byte[] byt = Encoding.UTF8.GetBytes(strimg);
            //newpath = "";
            try
            {
                MemoryStream ms = new MemoryStream(byt);
                Bitmap bt = new Bitmap(ms);

                bt.Save(newpath);
                bre = true;
            }
            catch (Exception)
            {
                bre = false;

                //MessageBox.Show("转换图片出错");
            }

            return bre;
        }
    }
}
